//
//  MacroDefinition.h
//  MacroDefinitionDemo
//
//  Created by 新风作浪 on 13-6-9.
//  Copyright (c) 2013年 SpinningSphere Labs. All rights reserved.
//

#ifndef MacroDefinition_h
#define MacroDefinition_h

//提交button的高度
#define submitBtn_High 40
#define submitBtn_BianJv 25



#define StoreTableHeaderBtn_x 10
#define StoreTableHeaderBtn_Y 15

#define searchBar_HIGHT 44

//
#define START_Y 50
#define START_X 30
#define START_WIDTH (SCREEN_WIDTH-START_X*2)
#define START_HIGHT 154

#define ORIGINAL_MAX_WIDTH 640.0f


//-------------------获取设备大小-------------------------
//NavBar高度
#define NavigationBar_HEIGHT 44
//获取屏幕 宽度、高度
#define SCREEN_X ([UIScreen mainScreen].bounds.origin.x)
#define SCREEN_Y ([UIScreen mainScreen].bounds.origin.y)
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

//-------------------获取设备大小-------------------------


//----------------------系统----------------------------
#pragma mark - 设备型号识别
#define is_IOS_7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)

//获取系统版本
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
#define CurrentSystemVersion [[UIDevice currentDevice] systemVersion]

//获取当前语言
#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])

//判断是否 Retina屏、设备是否%fhone 5、是否是iPad
#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)


//判断是真机还是模拟器
#if TARGET_OS_IPHONE
//iPhone Device
#endif

#if TARGET_IPHONE_SIMULATOR
//iPhone Simulator
#endif

//检查系统版本
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)


//----------------------系统----------------------------


//----------------------内存----------------------------

//使用ARC和不使用ARC
#if __has_feature(objc_arc)
//compiling with ARC
#else
// compiling without ARC
#endif

#pragma mark - common functions
#define RELEASE_SAFELY(__POINTER) { [__POINTER release]; __POINTER = nil; }

//释放一个对象
#define SAFE_DELETE(P) if(P) { [P release], P = nil; }

#define SAFE_RELEASE(x) [x release];x=nil



//----------------------内存----------------------------


//----------------------图片----------------------------

//读取本地图片
#define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]

//定义UIImage对象
#define IMAGE(A) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:A ofType:nil]]

//定义UIImage对象
#define ImageNamed(_pointer) [UIImage imageNamed:[UIUtil imageName:_pointer]]

//建议使用前两种宏定义,性能高于后者
//----------------------图片----------------------------



//----------------------颜色类---------------------------
// rgb颜色转换不带透明度（16进制->10进制）
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
// rgb颜色转换带透明度（16进制->10进制）
#define UIColorFromRGBA(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:((float)((rgbValue & 0xFF000000) >> 24))/255.0]

//带有RGBA的颜色设置
#define COLOR(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]

// 获取RGB颜色
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define RGB(r,g,b) RGBA(r,g,b,1.0f)

//字体颜色
#define FONT_COLOR [UIColor colorWithRed:90.0f/255.0f green:90.0f/255.0f blue:90.0f/255.0f alpha:1];

//清除背景色
#define CLEARCOLOR [UIColor clearColor]
//常用蓝色
//#define BLUE_COLOR [UIColor colorWithRed:0.25098 green:0.6 blue:1.0 alpha:1.0]
#define BLUE_COLOR [UIColor colorWithRed:34.0f/255.0f green:196.0f/255.0f blue:255.0f/225.0f alpha:0.9]
//常用灰色
#define GRAY_COLOR [UIColor colorWithRed:128.0f/255.0f green:128.0f/255.0f blue:128.0f/225.0f alpha:1]

#pragma mark - color functions
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

//----------------------颜色类--------------------------

//----------------------字体大小类--------------------------
#define MAX_BIG_FONT_18 [UIFont systemFontOfSize:18]//特大号字
#define TITLLE_FONT_17 [UIFont systemFontOfSize:17]//标题栏字号
#define LISTANDBTN_FONT_16 [UIFont systemFontOfSize:16]//如：列表文字；二级分类 商城提交详情详情页发货状态、大button按钮
#define ANNOTATION_FONT_13 [UIFont systemFontOfSize:13]//如：宝贝标题
#define LISTANDBTN_FONT_14 [UIFont systemFontOfSize:14]
#define LISTTIPS_FONT_12 [UIFont systemFontOfSize:12]//列表上面提示文字
#define THELABEL_FONT_11 [UIFont systemFontOfSize:11]//如：商品包邮 销量 等信息
#define BOTTOM_FONT_10 [UIFont systemFontOfSize:10]//如：底部button icon 配字
#define MIMI_FONT_9 [UIFont systemFontOfSize:9]//如：自营 包邮 等信息
#define BOLDFONT_15 [UIFont boldSystemFontOfSize:16]//订单列表实付金额加粗字
//----------------------字体大小类--------------------------

//----------------------其他----------------------------

//方正黑体简体字体定义
#define FONT(F) [UIFont fontWithName:@"FZHTJW--GB1-0" size:F]


//定义一个API
#define APIURL                @"http://xxxxx/"
//登陆API
#define APILogin              [APIURL stringByAppendingString:@"Login"]

//设置View的tag属性
#define VIEWWITHTAG(_OBJECT, _TAG)    [_OBJECT viewWithTag : _TAG]
//程序的本地化,引用国际化的文件
#define MyLocal(x, ...) NSLocalizedString(x, nil)

//G－C－D
#define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
#define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)

//NSUserDefaults 实例化
#define USER_DEFAULT [NSUserDefaults standardUserDefaults]


//由角度获取弧度 有弧度获取角度
#define degreesToRadian(x) (M_PI * (x) / 180.0)
#define radianToDegrees(radian) (radian*180.0)/(M_PI)



//单例化一个类
#define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) \
\
static classname *shared##classname = nil; \
\
+ (classname *)shared##classname \
{ \
@synchronized(self) \
{ \
if (shared##classname == nil) \
{ \
shared##classname = [[self alloc] init]; \
} \
} \
\
return shared##classname; \
} \
\
+ (id)allocWithZone:(NSZone *)zone \
{ \
@synchronized(self) \
{ \
if (shared##classname == nil) \
{ \
shared##classname = [super allocWithZone:zone]; \
return shared##classname; \
} \
} \
\
return nil; \
} \
\
- (id)copyWithZone:(NSZone *)zone \
{ \
return self; \
}

#define UMSYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

#define _IPHONE80_ 80000

//**********************左边栏推出view判断************
#define LEXIAO_SUDI_VC @"ExpressViewController"
#define LEXIAO_USER_HOME_VC @"UserHomeViewController"
#define LEXIAO_SUDI_HOME_VC @"ExpressHomeViewController"
#define LEXIAO_STORE_HOME_VC @"StoreViewController"
#define LEXIAO_EDIT_HOME_VC @"SettingViewController"


//****************************设置****************************
#define LEXIAO_BANQUAN @"Copyright © 2015 LEXIAO All Right Reserved" //乐校 版权
#define USERDEFAULTS_GET(i) [[NSUserDefaults standardUserDefaults] objectForKey:i]
#define USERDEFAULTS_SET(m,i) [[NSUserDefaults standardUserDefaults] setObject:m forKey:i]
#define USERDEFAULTS_DELET(i) [[NSUserDefaults standardUserDefaults] removeObjectForKey:i]

//*****************推送设备token************
#define LEXIAO_DEVICE_TOKEN @"device_token"

//******************服务器地址************************
#define FORMAL @"http://hhr.lexiao360.com/"

#endif
